import axios from '@/api/interceptor';
import type { RouteRecordNormalized } from 'vue-router';
import { UserState } from '@/store/modules/user/types';
import { LoginData, LoginRes, MenuData, ChangeLoginData, ForgetPassWord } from './user.d';


export function login(data: LoginData) {
  return axios.post<LoginRes>('/user/login', data);
}

export function logout() {
  return axios.post<LoginRes>('/user/logout');
}

export function getUserInfo() {
  return axios.post<UserState>('/user/info');
}

export function getMenuList(id: number) {
  return axios.post<MenuData>('/base/user/resource', {id});
}

export function changePassword(data: ChangeLoginData) {
  return axios.put<LoginRes>('/user', data);
}

export function forgetPassWord(data: ForgetPassWord) {
  return axios.put<null>('/user/forget/pwd', data);
}

// export function getMenuList() {
//   return axios.post<RouteRecordNormalized[]>('/api/user/menu');
// }
